package com.tianya.dream.recall.controller;

import java.util.List;

import com.tianya.common.web.core.domain.AjaxResult;
import com.tianya.dream.common.core.controller.BaseController;
import com.tianya.common.web.core.page.TableDataInfo;
import com.tianya.dream.recall.domain.Note;
import com.tianya.dream.recall.service.INoteService;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 个人日记文档 信息操作处理
 *
 * @author zcx
 * @date 2021-08-25 16:06:04
 */
@Controller
@RequestMapping("/recall/note")
public class NoteController extends BaseController {
    private String prefix = "recall/note";

	@Autowired
	private INoteService noteService;

	/**
	 * 查询个人日记文档列表
	 */
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Note note){
		startPage();
        List<Note> list = noteService.selectNoteList(note);
		return getDataTable(list);
	}

	/**
	 * 新增保存个人日记文档
	 */
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Note note){
		return toAjax(noteService.insertNote(note));
	}

	/**
	 * 修改保存个人日记文档
	 */
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Note note){
		return toAjax(noteService.updateNote(note));
	}

	/**
	 * 删除个人日记文档
	 */
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(long id){
		return toAjax(noteService.deleteNoteById(id));
	}

	/**
	 * 删除个人日记文档
	 */
	@PostMapping( "/removes")
	@ResponseBody
	public AjaxResult removes(String ids){
		return toAjax(noteService.deleteNoteByIds(ids));
	}

}
